<html>
<head><meta charset="utf-8"><title>Derive clone on a generic · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Derive.20clone.20on.20a.20generic.html">Derive clone on a generic</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="192952936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Derive%20clone%20on%20a%20generic/near/192952936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Martin Asquino <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Derive.20clone.20on.20a.20generic.html#192952936">(Apr 05 2020 at 10:34)</a>:</h4>
<p>Hi! I'm having a difficult time understanding why this works: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=324b11e7212a1932c79d3a43c58f796e" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=324b11e7212a1932c79d3a43c58f796e">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=324b11e7212a1932c79d3a43c58f796e</a><br>
but this doesn't: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=65c5f7564fd56aa8ba2f93e6c7637517" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=65c5f7564fd56aa8ba2f93e6c7637517">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=65c5f7564fd56aa8ba2f93e6c7637517</a></p>
<p>What am I missing here? <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="192953769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Derive%20clone%20on%20a%20generic/near/192953769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Martin Asquino <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Derive.20clone.20on.20a.20generic.html#192953769">(Apr 05 2020 at 10:59)</a>:</h4>
<p>Also, manually implementing clone works alright <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=65c5f7564fd56aa8ba2f93e6c7637517" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=65c5f7564fd56aa8ba2f93e6c7637517">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=65c5f7564fd56aa8ba2f93e6c7637517</a></p>



<a name="192953816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Derive%20clone%20on%20a%20generic/near/192953816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Derive.20clone.20on.20a.20generic.html#192953816">(Apr 05 2020 at 11:00)</a>:</h4>
<p>I think it's because <code>Arc</code> only implements Clone for Sized types, and the second Client type is generic over any type. And I don't think <code>#[derive(Clone)</code> works here, even if you use Sized bounds in the struct</p>



<a name="192953832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Derive%20clone%20on%20a%20generic/near/192953832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Derive.20clone.20on.20a.20generic.html#192953832">(Apr 05 2020 at 11:00)</a>:</h4>
<p><span class="user-mention silent" data-user-id="246514">Martin Asquino</span> <a href="#narrow/stream/122651-general/topic/Derive.20clone.20on.20a.20generic/near/192953769" title="#narrow/stream/122651-general/topic/Derive.20clone.20on.20a.20generic/near/192953769">said</a>:</p>
<blockquote>
<p>Also, manually implementing clone works alright <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=65c5f7564fd56aa8ba2f93e6c7637517" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=65c5f7564fd56aa8ba2f93e6c7637517">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=65c5f7564fd56aa8ba2f93e6c7637517</a></p>
</blockquote>
<p>Same link as second example</p>



<a name="192954110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Derive%20clone%20on%20a%20generic/near/192954110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Martin Asquino <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Derive.20clone.20on.20a.20generic.html#192954110">(Apr 05 2020 at 11:09)</a>:</h4>
<p>Oh, my bad, here goes: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=d3f88d0d7f91ac0a1c69a6a395c537ad" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=d3f88d0d7f91ac0a1c69a6a395c537ad">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=d3f88d0d7f91ac0a1c69a6a395c537ad</a></p>



<a name="192954187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Derive%20clone%20on%20a%20generic/near/192954187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Martin Asquino <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Derive.20clone.20on.20a.20generic.html#192954187">(Apr 05 2020 at 11:11)</a>:</h4>
<p>makes sense, but I guess I don't understand why setting the <code>Sized</code> constraint on the generic types doesn't do the trick now</p>



<a name="192954504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Derive%20clone%20on%20a%20generic/near/192954504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Derive.20clone.20on.20a.20generic.html#192954504">(Apr 05 2020 at 11:20)</a>:</h4>
<p>Look's like it's a known problem, but hard to fix: <a href="https://github.com/rust-lang/rust/issues/26925" title="https://github.com/rust-lang/rust/issues/26925">https://github.com/rust-lang/rust/issues/26925</a></p>



<a name="192954854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Derive%20clone%20on%20a%20generic/near/192954854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Martin Asquino <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Derive.20clone.20on.20a.20generic.html#192954854">(Apr 05 2020 at 11:30)</a>:</h4>
<p>oh nice find! I think I kinda understand now <span aria-label="grinning" class="emoji emoji-1f600" role="img" title="grinning">:grinning:</span></p>



<a name="192954858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Derive%20clone%20on%20a%20generic/near/192954858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Martin Asquino <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Derive.20clone.20on.20a.20generic.html#192954858">(Apr 05 2020 at 11:30)</a>:</h4>
<p>thank you!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>